$:.unshift(File.expand_path(File.dirname(__FILE__)+"/../ext"))
$:.unshift(File.expand_path(File.dirname(__FILE__)+"/../lib"))
require 'alglib_ext'
require 'matrix'
class Matrix
    def to_alglib_matrix
        a_matrix=Alglib_ext::Real2dArray.new
        a_matrix.setbounds(0,row_size-1,0,column_size-1)
        for x in 0...row_size
            for y in 0...column_size
                a_matrix[x,y]=self[x,y]
            end
        end
        a_matrix
    end
end
require 'alglib/linearregression.rb'
require 'alglib/logit.rb'
require 'alglib/correlation.rb'

module Alglib
    VERSION = '1.0.1'
    
    def self.array_to_real1darray(a)
        v=Alglib_ext::Real1dArray.new
        Alglib_ext.array_to_real1d(a,v)
        v
    end
    
    def self.real2darray_to_array(a)
        lr=a.getlowbound(1)
        lc=a.getlowbound(2)
        hr=a.gethighbound(1)
        hc=a.gethighbound(2)
        out=[]
        (lr..hr).each{|x|
            row=[]
            (lc..hc).each{|y|
                row[y]=a[x,y]
            }
            out[x]=row
        }
        out
    end
end
